package com.tt.fashionWebSite.dao.jpa;

import com.tt.fashionWebSite.dao.SizeAoTuVanDao;
import com.tt.fashionWebSite.domain.SizeAoTuVan;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by PC on 11/28/14.
 */
@Repository("sizeAoTuVan")
public class SizeAoTuVanJpaDao extends GenericJpaDao<SizeAoTuVan,String> implements SizeAoTuVanDao {
    public SizeAoTuVanJpaDao(){
        super(SizeAoTuVan.class);
    }

    @Override
    public SizeAoTuVan getInfoByUser(String maTV, String gender, Long type) {
       List<SizeAoTuVan> sizeAoTuVans =  getEntityManager().createNamedQuery(SizeAoTuVan.GET_INFO_BY_USER, SizeAoTuVan.class)
              .setParameter("maTV", maTV)
              .setParameter("gender", gender)
               .setParameter("type",type)
              .getResultList();
       if(sizeAoTuVans != null && sizeAoTuVans.size() > 0) {
          return sizeAoTuVans.get(0);
       }
       return null;
    }

}
